<?php
//filename : m_reqlayanan.php

require_once APPPATH.'models/gnc_db_mysql'.EXT;

class M_REQLAYANAN extends Gnc_db_mysql {
	protected $data_source	= 'inf_t_request';
	
	public function add($data, $table = NULL) {
			$query = $this->build_insert_query($table, $data);
			$this->send_email($data);
			$temp = $this->db->query($query);
			return $temp;
	}
	function send_email($data)
	{		
		$nip = $data['nip_pemohon'];
		$query= "select key_sys_user from sdm_m_pegawai where sdm_m_pegawai.nip ='".$nip."'";
		$ksuArr = $this->db->query($query);
		$ksuArr = $ksuArr->result_array();
		$ksu=$ksuArr[0];
		
		$query= "select email from sys_m_user where sys_m_user.nkey ='".$ksu['key_sys_user']."'";

		$accmailArr = $this->db->query($query);
		$accmailArr = $accmailArr->result_array();
		$accmail=$accmailArr[0];
		$accmailfrom= $accmail['email'];
		$receivermail= "duktek@del.ac.id";
		$ccmail= "";
		$subjek="Request Layanan  Duktek";
						
		$this->load->library('email');
		$head="Petugas Duktek Ysh.,\n";
		$disclimer = "\n\nTerimakasih\n\n\n====================================\nEmail ini dikirimkan oleh Aplikasi SI Del";

		$this->email->from($accmailfrom);
		$this->email->to($receivermail);
		$this->email->cc($ccmail);		
		$this->email->subject($subjek);
		$this->email->message($head.$data['perihal'].$disclimer);
			
		$this->email->send();
		
	}	
}

?>
